package ch.unisi.inf.gui;


import java.awt.*;
import javax.swing.*;

public class ListRenderer extends JLabel implements ListCellRenderer{
	
	final static ImageIcon longIcon = new ImageIcon("src/images/folder.png");
    final static ImageIcon shortIcon = new ImageIcon("src/images/folder.png");

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		
		String s = value.toString();
		setText(s);
		setIcon((s.length()> 20) ? longIcon : shortIcon);
		if(isSelected){
			setBackground(list.getSelectionBackground());
			setForeground(list.getSelectionForeground());
			
	}else{
		setEnabled(list.isEnabled());
		setBackground(list.getBackground()); 
		setForeground(list.getForeground());
	}
		
		Font font = new Font("Serif", Font.BOLD, 18);
		setEnabled(list.isEnabled());
		setFont(font);
		setOpaque(true);
		return this;
	}
}
